﻿<div>
    <div style="margin-bottom:20px; margin-left:10px;" class = "pagination">
            Found Items: 
        <span style="color:blue">@ViewBag.ItemsCount</span>
        <span style="margin-left:440px;" class = "pagination">
@if(ViewBag.itemOnPage == 10 )
{
                @Ajax.ActionLink("25 item on page", "ItemTable", new { orderItemsBy = ViewBag.NameSortParm ,itemOnPage = 25,page = ViewBag.currentPage ,searchString = ViewBag.searchString,listSelectField = ViewBag.listSelectField,listSelectCondition = ViewBag.listSelectCondition}, new AjaxOptions
{
    UpdateTargetId = "table",
    LoadingElementId = "loading",
    LoadingElementDuration = 1000
})
}
            else{
                    @Ajax.ActionLink("10 item on page", "ItemTable", new { orderItemsBy = ViewBag.NameSortParm ,itemOnPage = 10,page = ViewBag.currentPage ,searchString = ViewBag.searchString,listSelectField = ViewBag.listSelectField,listSelectCondition = ViewBag.listSelectCondition }, new AjaxOptions
{
    UpdateTargetId = "table",
    LoadingElementId = "loading",
    LoadingElementDuration = 1000
})
    
}
        </span>
    </div>

    <div>

    <table class="rounded-corner">
        <thead>
        <tr>
            <th  class="rounded-company"></th>
            <th>@Ajax.ActionLink("Item Name","ItemTable",new { orderItemsBy = ViewBag.NameSortParm ,itemOnPage = ViewBag.itemOnPage,page = ViewBag.currentPage ,searchString = ViewBag.searchString,listSelectField = ViewBag.listSelectField,listSelectCondition = ViewBag.listSelectCondition},new AjaxOptions{ UpdateTargetId="table"})</th>
            <th>@Ajax.ActionLink("Description", "ItemTable", new { orderItemsBy = ViewBag.SortByDescription,itemOnPage = ViewBag.itemOnPage, page = ViewBag.currentPage, searchString = ViewBag.searchString, listSelectField = ViewBag.listSelectField, listSelectCondition = ViewBag.listSelectCondition }, new AjaxOptions { UpdateTargetId = "table" })</th>
            <th><span style="color:white;">Price</span></th>
            <th class="rounded-q4">Edit</th>
        </tr>
        </thead>
        <tbody>
    @foreach (var c in ViewBag.Items)
    {
        <tr>
            <td></td>
            <td>@c.Name</td>
            <td>@c.Description</td>
            @if (c.ItemDimensions.Count != 0){
           <td> @c.ItemDimensions[0].Price </td>}
            else 
            {
                <td>No price yet</td>
            }
            
           <td><a href="@Url.Action("CreateItemDimension", "Item", new { @id = c.ItemId  })"><img src="../../Content/images/user_edit.png" alt="Edit" title="Edit" border="0" /></a>
                </tr>
               
    }
    @if (ViewBag.Items.Count != ViewBag.itemOnPage)
    {
        for (int i = 0; i <= ViewBag.itemOnPage - ViewBag.Items.Count; i++)
        {
            <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
        }
    }
    </tbody>
    </table>
      </div>
     <span id="numberOfPage">Page #: @ViewBag.currentPage from @ViewBag.lastPage</span>
        <div class="pagination">
           

         @if (ViewBag.currentPage == 1)
         {
             <span class="disabled">first</span>
             <span class="disabled">< prev</span>
         }
         else
         
         {
             <span>

                 @Ajax.ActionLink("first", "ItemTable", new { 
                
                  itemOnPage = ViewBag.itemOnPage,
                  searchString = ViewBag.searchString, 
                  listSelectField = ViewBag.listSelectField, 
                  listSelectCondition = ViewBag.listSelectCondition, 
                  orderItemsBy = ViewBag.currentSortItemsBy, 
                  page = 1 
        
             },new AjaxOptions{ UpdateTargetId="table", LoadingElementId="loading", 
                                                        LoadingElementDuration=1000})

             </span>
             
             <span>
                 @Ajax.ActionLink("< prev", "ItemTable", new { 
                itemOnPage = ViewBag.itemOnPage,
                  searchString = ViewBag.searchString, 
                  listSelectField = ViewBag.listSelectField, 
                  listSelectCondition = ViewBag.listSelectCondition, 
                  orderItemBy = ViewBag.currentSortItemsBy, 
                  page = ViewBag.currentPage - 1 
                  
              }, new AjaxOptions{ UpdateTargetId="table", LoadingElementId="loading", 
                                                          LoadingElementDuration=1000})

             </span>
             
             
         }
         @if (ViewBag.ItemsCount <= ViewBag.currentPage * ViewBag.itemOnPage)
         {
             <span class="disabled">next ></span>
             <span class="disabled">last</span>
         }
            else
            {
                 <span>

                     @Ajax.ActionLink("next >", "ItemTable", new {
                        itemOnPage = ViewBag.itemOnPage,
                      searchString =ViewBag.searchString, 
                      listSelectField =ViewBag.listSelectField, 
                      listSelectCondition = ViewBag.listSelectCondition, 
                      orderItemsBy = ViewBag.currentSortItemsBy, 
                      page = ViewBag.currentPage + 1 
              
                  }, new AjaxOptions{ UpdateTargetId="table", LoadingElementId="loading", 
                                                              LoadingElementDuration=1000})

                 </span>
                 <span>
                     @Ajax.ActionLink("last", "ItemTable", new {
                        itemOnPage = ViewBag.itemOnPage,
                      searchString =ViewBag.searchString, 
                      listSelectField =ViewBag.listSelectField, 
                      listSelectCondition = ViewBag.listSelectCondition, 
                      orderItemsBy = ViewBag.currentSortItemsBy, 
                      page = ViewBag.lastPage
              
                  }, new AjaxOptions{ UpdateTargetId="table", LoadingElementId="loading", 
                                                              LoadingElementDuration=1000})

                 </span>
         }
   </div>
    
</div>